clear all; close all;

%E5aI_pc = PrimaryPRNCode('E5aI', 10230, 1); 
E5aI_pc = PrimaryPRNCode('E5aI', 20000, 1); 

c1 = E5aI_pc.getCode(1, -3*E5aI_pc.ChipPeriod);
c2 = E5aI_pc.getCode(1, 0);
c1c2_corr = xcorr(-2*c1+1, -2*c2 +1);
[val ind] = max(c1c2_corr);
ind = ind - E5aI_pc.NumberOfUpsampledSamples;
shift_in_chips = round(ind/E5aI_pc.NumberOfUpsampledSamples...
											* E5aI_pc.NumberOfChips);
fprintf(1,'The time shift of prim. code is = %f [chips] \n', shift_in_chips);
figure(1);clf;
plot(c1c2_corr);

E5aI_sc = SecondaryPRNCode('E5aI');
sc1 = E5aI_sc.getCode(1, 3);
sc2 = E5aI_sc.getCode(1, 0);
sc1sc2_corr = xcorr(-2*sc1+1, -2*sc2 +1);
[val ind] = max(sc1sc2_corr);
ind = ind - E5aI_sc.NumberOfChips;
fprintf(1,'The time shift of sec. code is = %f [chips] \n', ind);
figure(2);clf;
plot(sc1sc2_corr);



